﻿using System;
using CommandRunner.Model;

namespace CommandRunner.Core
{
    public class ConfigurationManagerSingleCommand : ICommandRunnerConfigurationManager
    {

        #region ICommandRunnerConfigurationManager Members
        public SimpleCommandList CommandList { get; private set; }
        #endregion

        public ConfigurationManagerSingleCommand(SimpleCommand simpleCommand)
        {
            CommandList = new SimpleCommandList() { simpleCommand };
        }

        public ConfigurationManagerSingleCommand(string command, string server, Nullable<int> port, string workingDirectory, bool interactive, bool monitorSuccess = true)
        {
            SimpleCommand simpleCommand = new SimpleCommand();
            simpleCommand.Execute = command;
            simpleCommand.Server = server;
            if (port != null)
                simpleCommand.Port = (int)port;
            simpleCommand.Monitor = monitorSuccess;
            simpleCommand.Wait = true;
            simpleCommand.WorkingDirectory = workingDirectory;
            simpleCommand.InteractiveWindow = interactive;

            CommandList = new SimpleCommandList() { simpleCommand };
        }
    }
}
